﻿using System;
using OSGeo.GDAL;
using System.IO;
using System.Windows;

namespace Okra.NstdaGisTool {
    public class GdalBinding {
        public static bool SetupGdalBindings() {
            string strBinPath = Directory.GetCurrentDirectory();
            string strEnvironmentPath = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Process);
            string strGdalPath = System.IO.Path.Combine(strBinPath, @"gdal_dll");
            strEnvironmentPath += ";" + strGdalPath; // no white space plzzzz 
            Environment.SetEnvironmentVariable("PATH", strEnvironmentPath, EnvironmentVariableTarget.Process);
            string strTemp = Environment.GetEnvironmentVariable("PATH");
            try {
                Gdal.AllRegister();
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
                return false;
                throw;
            }
            return true;
        }
    }
}